$(function () {
    var price_double = 0;
    var goods_type_amount = $('.goods_type>ul>li').length
    //图片点击获取边框效果
    function pic(x) {
        $('.a_i:eq('+x+')').mouseover(function () {
            $('.i_2').removeClass('i')
           $('.i_2:eq('+x+')').addClass('i')
            $('.i_pic').attr('src','http://127.0.0.1:3002/images/cw/big_books_'+x+'.jpg')
        })
    }
    for(let i=0;i<2;i++){
        pic(i)
    }
    //获取更多图片
    $('.more').click(function () {
        $('.more').css('display',"none")
        $('.more_goods').css('display',"block")
    })
    $('.less').click(function () {
        $('.more').css('display',"block")
        $('.more_goods').css('display',"none")
    })
//选中的商品后价格变化

    function goods_type_press(num) {
        $('.goods_type>ul>li:eq('+num+')').click(function () {
            if($('.i_3:eq('+num+')').is('.i_i')){
                console.log("有")
                $('.i_3:eq('+num+')').removeClass('i_i')
                price_double--
            }
            else{
                $('.i_3:eq('+num+')').addClass('i_i')
                price_double++
            }
            let vals = $('.num').val()
            $('.goods_price_all>span').text(42*price_double*vals + ".00")
        })
    }
    for (let i=0;i<goods_type_amount;i++) {
        goods_type_press(i)
    }
//商品数量
    $('.add').click(function () {
        let vals = $('.num').val();
        vals++
        $('.num').val(vals)
        $('.goods_price_all>span').text(42*price_double*vals + ".00")
    })
    $('.reduce').click(function () {
        let vals = $('.num').val();
        if(vals>0){
            vals--
        }
        $('.goods_price_all>span').text(42*price_double*vals + ".00")
        $('.num').val(vals)
    })
})